﻿#ifndef VIDEORENDERER_IMPL_H
#define VIDEORENDERER_IMPL_H
//#include <IAgoraMediaEngine.h>
#include <QObject>
#include <mutex>

class AVideoWidget;

//Instances of VideoRenderImpl is created and destroyed by Agora Media Engine.
//AVideoWidget is created and destroyed by the APP
//VideoRenderImpl must check if the video widget is alive whenever access to the view.
class VideoRenderImpl : public QObject {
    Q_OBJECT
public:
    VideoRenderImpl();
    ~VideoRenderImpl() override;
    virtual void release()  {delete this;}
    virtual int initialize()  {return 0;}
    virtual int deliverFrame(const agora::media::IVideoFrame& videoFrame, int rotation, bool mirrored);
public slots:
    void handleWidgetInvalidated();
    void handleViewSizeChanged(int width, int height);
private:
    AVideoWidget* m_view;
//    agora::media::IExternalVideoRenderCallback* m_renderCallback;
    std::mutex m_mutex;
};


#endif // VIDEORENDERER_IMPL_H
